<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="demo" index1="111" class="nav">123123</div>
    <script>
        let div =document.querySelector('div');
        console.log(typeof div);
        console.log(div);

        // 1.获取对象自带的属性
        console.log(div.id);
        console.log(div.class);
        console.log(div.index1);
        console.log(div.className);

        // 2.设置获取自定义属性(相当于给对象动态的添加属性)
       div.dataset.index4='data';
        console.log(div.dataset.index4)

        let get1=div.setAttribute('index3','王泽');
        console.log(get1);

        console.log(div.getAttribute('class'));

        console.log(div.getAttribute('index1'));
        div.setAttribute('index1','剑圣');
        console.log(div.setAttribute('index2','huoshao'));

        // 3.移除元素
        // div.removeAttribute('class');
    </script>
</body>
</html>